<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:t="http://myfaces.apache.org/tomahawk">

    <f:view>
        <f:loadBundle var="text" basename="#{quotationList.bundleName}"/>
        <head>
            <title>#{text['quotationList.title']}</title>
            <meta name="heading" content="#{text['quotationList.heading']}"/>
            <meta name="menu" content="OperationMenu"/>
        </head>
        <body id="quotationList">
        <h:form id="editquotation">
                        
            <h:commandButton value="#{text['button.search']}" type="submit" action="#{quotationList.execute}" id="search" styleClass="button"/>
            <h:commandButton value="#{text['button.add']}" action="#{quotationForm.add}" id="add" immediate="true" styleClass="button"/>
            <h:commandButton value="#{text['button.done']}" action="mainMenu" id="close" immediate="true" styleClass="button"/>
            
            <h:outputText></h:outputText>
            <h:panelGroup>
                <table>
                    <tr>
                        <td>
                    <t:htmlTag value="div">
                        <h:outputLabel styleClass="desc" for="id" value="#{text['quotation.id']}"/>
                        <h:inputText styleClass="text medium" id="id" value="#{quotationList.id}"/>
                        <t:message for="id" styleClass="fieldError"/>
                    </t:htmlTag>
                    </td>
                    <td>
                    <t:htmlTag value="div">
                        <h:outputLabel styleClass="desc" for="description" value="#{text['quotation.description']}"/>
                        <h:inputText styleClass="text medium" id="description" value="#{quotationList.description}"/>
                        <t:message for="description" styleClass="fieldError"/>
                    </t:htmlTag>
                    </td>
                    <td>
                    <t:htmlTag value="div">
                        <h:outputLabel styleClass="desc" for="date" value="#{text['quotation.transDate']}"/>
                        <t:inputCalendar id="date" value="#{quotationList.date}" renderAsPopup="true"
                                         popupDateFormat="dd/MM/yyyy" popupTodayString="Hoy es "
                                         popupWeekString="Semana" lang="es">
                        </t:inputCalendar>
                        <t:message for="date" styleClass="fieldError"/>
                    </t:htmlTag>
                    </td>
                    </tr>
                    <tr>
                        <td>
                    <t:htmlTag value="div">
                        <h:outputLabel styleClass="desc" for="company" value="#{text['quotation.company']}"/>
                        <h:selectOneMenu value="#{quotationList.company}" id="company" styleClass="select">
                            <f:selectItem itemLabel="Todas"/>
                            <t:selectItems value="#{quotationList.companies}" var="company" itemLabel="#{company.description}" itemValue="#{company}"/>
                            <f:converter converterId="objconverter"/>
                        </h:selectOneMenu>
                        <t:message for="company" styleClass="fieldError"/>
                    </t:htmlTag>
                    </td>
                    <td>
                    <t:htmlTag value="div">
                        <h:outputLabel styleClass="desc" for="status" value="#{text['quotation.status']}"/>
                        <h:selectOneMenu value="#{quotationList.stStatus}" id="status" styleClass="select">
                            <f:selectItem itemLabel="Todos"/>
                            <f:selectItem itemLabel="SOLICITADA" itemValue="SOLICITADA"/>
                            <f:selectItem itemLabel="APROBADA" itemValue="APROBADA"/>
                            <f:selectItem itemLabel="CANCELADA" itemValue="CANCELADA"/>
                            <f:selectItem itemLabel="FACTURADA" itemValue="FACTURADA"/>
                        </h:selectOneMenu>
                        <t:message for="status" styleClass="fieldError"/>
                    </t:htmlTag>
                    </td>
                    </tr>
                </table>
            </h:panelGroup>
            <h:outputText></h:outputText>

            <t:dataTable id="quotations" var="quotation" style="margin-top: 10px"
                         value="#{quotationList.quotations}" rows="25" sortColumn="#{quotationList.sortColumn}"
                         sortAscending="#{quotationList.ascending}" styleClass="scrollerTable table"
                         headerClass="standardTable_Header" rowClasses="standardTable_Row1,standardTable_Row2"
                         columnClasses="standardTable_Column,standardTable_Column,standardTable_Column,standardTable_Column,standardTable_ColumnCentered">
                <t:column width="5%">
                    <f:facet name="header">
                        <t:commandSortHeader columnName="id" arrow="true">
                            <h:outputText value="#{text['quotation.id']}" />
                        </t:commandSortHeader>
                    </f:facet>
                    <h:commandLink action="#{quotationForm.edit}" value="#{quotation.id}">
                        <f:param name="id" value="#{quotation.id}"/>
                        <f:param name="from" value="list"/>
                    </h:commandLink>
                </t:column>
                <t:column width="30%">
                    <f:facet name="header">
                        <t:commandSortHeader columnName="description" arrow="true">
                            <h:outputText value="#{text['quotation.description']}" />
                        </t:commandSortHeader>
                    </f:facet>
                    <h:outputText value="#{quotation.description}" escape="true"/>
                </t:column>
                <t:column width="10%" title="Fecha de creacion">
                    <f:facet name="header">
                        <t:commandSortHeader columnName="transDate" arrow="true">
                            <h:outputText value="#{text['quotation.transDate']}"/>
                        </t:commandSortHeader>
                    </f:facet>
                    <h:outputText value="#{quotation.transDate}" escape="true">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </h:outputText>
                </t:column>
                <t:column width="15%">
                    <f:facet name="header">
                        <h:outputText value="#{text['quotation.company']}" />
                    </f:facet>
                    <h:outputText value="#{quotation.company.description}" escape="true"/>
                </t:column>
                <t:column width="20%">
                    <f:facet name="header">
                        <h:outputText value="#{text['quotation.contact']}" />
                    </f:facet>
                    <h:outputText value="#{quotation.contact.firstName}" escape="true"/>
                    <h:outputText value=" #{quotation.contact.lastName}" escape="true"/>
                </t:column>
                <t:column width="10%" title="Estatus producción: #{quotation.deliveryStatus}">
                    <f:facet name="header">
                        <t:commandSortHeader columnName="status">
                            <h:outputText value="#{text['quotation.status']}" />
                        </t:commandSortHeader>
                    </f:facet>
                    <h:outputText value="#{quotation.status}"/>
                </t:column>
            </t:dataTable>
            <t:saveState id="save1" value="#{quotationList.quotations}"/>
            <t:saveState id="save2" value="#{quotationList.id}"/>
            <ui:include src="/common/tableFooter.xhtml">
                <ui:param name="tableName" value="quotations"/>
            </ui:include>

            <script type="text/javascript">
                highlightTableRows("editquotation:quotations");
            </script>
            <script type="text/javascript">
                Event.observe(window, 'load',
                function(){
                    <c:if test="#{printQuo}">
                        alert('impr');
                        window.open('/birt-viewer/run?__report=rpt_cotizacion.rptdesign&amp;p_cotizacion=' + #{quotationForm.quotation.id} + '__format=html','SuArte','height=700,width=800,status=yes,toolbar=no,menubar=yes,location=no,resizable=yes');
                        return false;
                    </c:if>
                });
            </script>
        </h:form>
    </body>
</f:view>
</html>